package Cyclic_structure;
/**
 * 求一个整数的阶乘 5! = 5*4*3*2*1
 * 20=5*4
 * 60=20*3
 * 120=60*2
 * 120=120*1//最后一步可以省略
 * */

public class while_demo2_anli {
    public static void main(String[] args) {
        //自己做的方法
        int i = 1;
        int total = 1;
        while(i<=5) {
            total*=i;
            i++;
        }
        System.out.println(total);

        //课上方法
        int number = 5;
        int factorial = number;
        while ( number > 2) {
            factorial*=number-1;
            number--;
        }
        System.out.println(factorial);
    }
}
